﻿using NetTaste;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
using System.Text.Json;
using System.Text.RegularExpressions;
using QiAdmin.Core;
using QiAdmin.Core.Utils.Encryption;

namespace QiAdmin.WebApi.MiddleWares
{
    public class CheckSize
    {
        readonly RequestDelegate _next;
        public CheckSize(RequestDelegate next)
        {
            _next = next;
        }
        public async Task InvokeAsync(HttpContext context)
        {
            if (context.Request.ContentLength > App.AppSettings.System.MaxRequestSize * 1024 * 1024)
            {
                await context.Response.WriteAsync(JsonConvert.SerializeObject(new ApiJsonResult(ResultType.Error, "请求过大")));
                return;
            }
            await _next(context);

        }
    }
}
